<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<div class="pad-10">
<div id="searchid" style="">
<form name="searchform" action="" method="get" >
<input type="hidden" value="<?php echo ROUTE_M;?>" name="m">
<input type="hidden" value="<?php echo ROUTE_C;?>" name="c">
<input type="hidden" value="<?php echo ROUTE_A;?>" name="a">
<input type="hidden" value="1" name="search">
<input type="hidden" value="<?php echo $catid;?>" name="catid">
<input type="hidden" value="<?php echo $pc_hash;?>" name="pc_hash">
<table width="100%" cellspacing="0" class="search-form">
    <tbody>
		<tr>
		<td>
		<div class="explain-col">			
			课程名称：<input name="name" type="text" value="<?php echo $_GET['name']?>" class="input-text" />
			<input type="submit" name="search" class="button" value="<?php echo L('search');?>" />
	</div>
		</td>
		</tr>
    </tbody>
</table>
</form>
</div>
<input type="hidden" value="" name="relation" id="relation">
<div class="table-list">
    <table width="100%" cellspacing="0" >
        <thead>
            <tr>
            	<th width="16"><input type="checkbox" value="" id="check_box" onclick="selectalls('id[]');"></th>
				<th align="left">课程名称</th>
				<th align="left">课程价格</th>
				<th align="left">上课日期</th>
				<th align="left">课程方形图</th>
            </tr>
        </thead>
    <tbody id="select_id">
	<?php if (!empty($infos)){ foreach($infos as $v) { ?>
	<tr onclick="select_list(this,<?php echo $v['id'];?>)" class="cu" title="<?php echo L('click_to_select');?>">
		<td align="center"><input class="inputcheckbox " name="id[]" value="<?php echo $v['id'];?>" type="checkbox"></td>
		<td align="left"><?php echo $v['name']?></td>

		<td align="left"><?php if(!empty($v['price'])){echo $v['price'];}else{echo '<font color="red">（未设置）</font>';}?></td>
		<td align="left"><?php if(!empty($v['course_day'])){echo $v['course_day'];}else{echo '<font color="red">（未设置）</font>';}?></td>
		<td align="left"><?php if(!empty($v['image_square'])){echo '<img src="'.$v['image_square'].'" height="60px">';}else{echo '<font color="red">（未设置）</font>';}?></td>
	</tr>
	 <?php } } else {
	 	echo "<tr><td colspan='5' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
	 	}?>
	    </tbody>
    </table>
    <div id="pages"><?php echo $pages;?></div>
</div>
</div>
<style type="text/css">
 .line_ff9966,.line_ff9966:hover td{
	background-color:#FF9966;
}
 .line_fbffe4,.line_fbffe4:hover td {
	background-color:#fbffe4;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
	function selectalls(name) {
		//alert($('#select_id tr .inputcheckbox').length);
		var objs = $('#select_id tr .inputcheckbox');
		var strs = '';
		if ($("#check_box").attr("checked")=='checked') {
			$("input[name='"+name+"']").each(function() {
	  			$(this).attr("checked","checked");
	  			
				$('#select_id tr').attr('class','line_ff9966');
			});
			for(var i=0; i<objs.length; i++){
				if (i == 0) {
					if(objs[i].checked) strs = objs[i].value;
				} else {
					if(objs[i].checked) strs +='|' + objs[i].value;
				}
			}
			$('#relation').val(strs);
		} else {
			$("input[name='"+name+"']").each(function() {
	  			$(this).removeAttr("checked");
	  			$('#select_id tr').attr('class','line_fbffe4')
	  			$('#relation').val('');
			});
		}
	}
	
	function select_list(obj,id) {
		var relation_ids =$('#relation').val();
		if($(obj).attr('class')=='line_ff9966' || $(obj).attr('class')==null) {
			$(obj).attr('class','line_fbffe4');
			$(obj).find('.inputcheckbox').removeAttr("checked");
			if(relation_ids !='' ) {
				var r_arr = relation_ids.split('|');
				var newrelation_ids = '';
				$.each(r_arr, function(i, n){
					if(n!=id) {
						if(i==0) {
							newrelation_ids = n;
						} else {
						 newrelation_ids = newrelation_ids+'|'+n;
						}
					}
				});
				$('#relation').val(newrelation_ids);
			}
		} else {
			$(obj).attr('class','line_ff9966');
			$(obj).find('.inputcheckbox').attr("checked","checked");
			if(relation_ids =='' ) {
				$('#relation').val(id);
			} else {
				relation_ids = relation_ids+'|'+id;
				$('#relation').val(relation_ids);
			}
		}
}
//-->
</SCRIPT>
</body>
</html>